<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>系统提示信息管理</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		.search-div{
		margin :10px;
		}
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
/*			jQuery("#searchForm").validate({
		    	submitHandler: function(form){
		    		var submit = function(){
		    			loading('正在提交，请稍等...');
		    			form.submit();
		            };
		    		loginPasswordPopup(submit);
				},
			});
*/			
			jQuery("#searchForm").validate({
				submitHandler: function(form){
					var notifyDate = $("#notifyDate").val();
					var today = new Date();
					if(notifyDate){
						var notify = new Date(notifyDate.replace(/-/g, "/"));
						if (notify > today){
							showTip("提示日期不能大于当前时间!");
							return;
						}
					}
					form.submit();
				}
		    });
			$("#contentTable tbody tr").click(function(e){
				if (!this.id) {
					return;
				}
				sessionStorage.parentPageNo = $("#pageNo").val();
				sessionStorage.notifyDate = $("#notifyDate").val();
				sessionStorage.status = $('input[name="status"]:checked').val();
				sessionStorage.finished = $('input[name="finished"]:checked').val();
				sessionStorage.employeeName = $("#employeeName").val();
				$("#contentTable tbody tr").removeClass("select_active");
				$(this).addClass("select_active");
				loginPasswordPopup("${ctx}/message/storeEmployeeTask/detail?id=" + this.id);
			});
			var currentSelectId = '${currentSelectId}';
			if(currentSelectId){
				$("#"+currentSelectId).addClass("select_active");
			} else {
				$("#contentTable tbody tr:first-child").addClass("select_active");
			}
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<div class="icon-buttons">
		<input type="button" class="leave-clean-session" data-inline="true" data-icon="back" data-iconpos="notext" value="返回"/>
	</div>
	<form:form id="searchForm" modelAttribute="storeEmployeeTask" action="${ctx}/message/storeEmployeeTask/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<fieldset data-role="controlgroup" data-type="horizontal">
			<legend>提示日期:</legend>
			<input type="date" id="notifyDate" data-inline="true" name="notifyDate" value="${notifyDate}"/>
		</fieldset>
		<fieldset data-role="controlgroup" data-type="horizontal">
	        <legend>查看状态:</legend>
	        <input type="radio" name="status" id="statusAll" value="-1" ${empty status || status == '-1'?'checked':''}>
	        <label for="statusAll">全部</label>
	        <input type="radio" name="status" id="statusUnread" value="0" ${status == '0'?'checked':''}>
	        <label for="statusUnread">未查看</label>
	        <input type="radio" name="status" id="statusRead" value="1" ${status == '1'?'checked':''}>
	        <label for="statusRead">已查看</label>
	    </fieldset>
		<fieldset data-role="controlgroup" data-type="horizontal">
	        <legend>完成状态:</legend>
	        <input type="radio" name="finished" id="finishedAll" value="-1" ${empty finished || finished == '-1'?'checked':''}>
	        <label for="finishedAll">全部</label>
	        <input type="radio" name="finished" id="unfinished" value="0" ${finished == '0'?'checked':''}>
	        <label for="unfinished">未完成</label>
	        <input type="radio" name="finished" id="finished" value="1" ${finished == '1'?'checked':''}>
	        <label for="finished">已完成</label>
	    </fieldset>
	    <fieldset data-role="controlgroup" data-type="horizontal">
			<legend>员工姓名:</legend>
			<input id="employeeName" name="employeeName" data-inline="true" type="text" value="${employeeName}"/>
		</fieldset>
		<input id="btnSubmit" data-inline="true" type="submit" value="查询"/>
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" data-role="table" class="ui-responsive table-stroke">
		<thead><tr><th>日期</th><th>员工</th><th>任务单类型</th><th>任务状态</th></tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="storeEmployeeTask">
			<tr id="${storeEmployeeTask.id}">
				<td>${fns:formatDate(storeEmployeeTask.taskDate, 'yyyy-MM-dd')}</td>
				<td>${storeEmployeeTask.employee.name}</td>
				<td>${fns:getDictLabel(storeEmployeeTask.type, 'task_type', '')}</td>
				<td>
				<c:if test="${storeEmployeeTask.viewed == 0}">
					未查看
				</c:if>
				<c:if test="${storeEmployeeTask.viewed == 1}">
					<c:if test="${storeEmployeeTask.completed == 0}">
						未完成
					</c:if>
					<c:if test="${storeEmployeeTask.completed == 1}">
						已完成
					</c:if>
				</c:if>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>
